cc.Class({
    extends: cc.Component,

    properties: {
        labContent: cc.Label,
        imgBackground: cc.Sprite,
    },
    mDelay: null,
    init(content, delay) {
        this.node.stopAllActions();
        this.node.scaleX = 0;

        this.labContent.string = content;

        this.labContent._updateRenderData(true);
        var textSize = this.labContent.node.getContentSize();
        this.imgBackground.node.setContentSize(textSize.width + 140, this.imgBackground.node.height);

        this.mDelay = delay || 3;
        this.scheduleOnce(this.show, 0);
    },

    show() {
        this.node.scaleX = 0;
        let action = cc.sequence(
            cc.scaleTo(0.3, 1, 1),
            cc.delayTime(this.mDelay),
            cc.scaleTo(0.3, 0, 1),
            cc.callFunc(() => {
                G.utils.putPoolNode('nodePoolToast', this.node);
            })
        );

        this.node.runAction(action);
    },
});
